home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / nice.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  2.9 KB  |  122 lines

  1. #
  2. # nice.test
  3. #
  4. # Tests for the nice command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: 
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. #
  22. # Fork without exec will not work under Tk, skip this test
  23. #
  24. if ![lempty [info commands button]] {
  25.     puts stderr "*************************************************************"
  26.     puts stderr "Nice tests are constructed in a way that does not work"
  27.     puts stderr "under Tk.  Test skipped."
  28.     puts stderr "*************************************************************"
  29.     puts stderr ""
  30.     return
  31. }
  32.  
  33. #
  34. # Right now, we depend on the base priority being zero.
  35. #
  36. if {[nice] != 0} {
  37.     puts stderr "*************************************************************"
  38.     puts stderr "Nice priority is [nice], not zero.  Most \"nice\" command"
  39.     puts stderr "test will fail (but everything is probably ok)"
  40.     puts stderr "*************************************************************"
  41.     puts stderr ""
  42. }
  43.  
  44. Test nice-1.1 {nice tests} {
  45.     nice 0 1
  46. } 1 {wrong # args: nice ?priorityincr?}
  47.  
  48. Test nice-1.2 {nice tests} {
  49.     nice
  50. } 0 {0}
  51.  
  52. Test nice-1.2 {nice tests} {
  53.     nice 0
  54. } 0 {0}
  55.  
  56. #
  57. # Since you can't nice back up unless you're root, we spawn a child process 
  58. # to run the nice tests.  
  59. #
  60.  
  61. set pid [fork]
  62.  
  63. #
  64. # Parent waits for child to complete.
  65. #
  66. if {$pid > 0} {
  67.     wait $pid
  68.     return
  69. }
  70.  
  71. Test nice-1.4 {nice tests} {
  72.     nice 8
  73. } 0 8
  74.  
  75. Test nice-1.5 {nice tests} {
  76.     nice 8
  77. } 0 16
  78.  
  79. Test nice-1.6 {nice tests} {
  80.     nice 20
  81. } 0 19
  82.  
  83. if {[id user] != "root"} {
  84.  
  85.     Test nice-1.7 {nice tests} {
  86.         set stat [catch {nice -1} msg]
  87.         set msg [string tolower $msg]
  88.         if {[lsearch {{not owner} {permission denied}} $msg] < 0} {
  89.             set stat [list $stat $msg]
  90.         }
  91.         set stat
  92.     } 0 1
  93.  
  94.     puts stderr "*************************************************************"
  95.     puts stderr "You are not running as `root', certain nice tests will be"
  96.     puts stderr "skipped"
  97.     puts stderr "*************************************************************"
  98.     exit
  99. }
  100.  
  101. Test nice-1.8 {nice tests} {
  102.     nice -1
  103. } 0 18
  104.  
  105. Test nice-1.10 {nice tests} {
  106.     nice -9
  107. } 0 9
  108.  
  109. Test nice-1.11 {nice tests} {
  110.     nice -10
  111. } 0 -1
  112.  
  113. Test nice-1.12 {nice tests} {
  114.     nice -10
  115. } 0 -11
  116.  
  117. Test nice-1.13 {nice tests} {
  118.     nice -10
  119. } 0 -20
  120.  
  121. exit
  122.